package com.gitee.sparta.core.cluster.strategy;

import com.gitee.sparta.core.bean.cluster.ClusterProtocol;
import com.gitee.sparta.core.cluster.balance.LoadBalance;
import com.gitee.sparta.core.process.feature.SpartaTaskDispatcherFeature;
import com.gitee.sparta.core.property.SpartaCoreProperties;
import io.netty.channel.ChannelHandlerContext;
import org.redisson.api.RedissonClient;

import java.nio.channels.SocketChannel;

/**
 * <p>
 * 由 leader 告知 follower 可以消费队列消息了
 * </p>
 *
 * @author zyred
 * @since v 0.0.2
 */
public class ConsumeBroadcastStrategy extends Strategy {

    public ConsumeBroadcastStrategy(RedissonClient client,
                                    LoadBalance loadBalance,
                                    SpartaCoreProperties properties) {
        super(client, loadBalance, properties);
    }

    @Override
    public void handle(ChannelHandlerContext ctx, SocketChannel sc, ClusterProtocol cp) {
        SpartaTaskDispatcherFeature.CHANNEL_QUEUE.add(cp.getTopics());
    }
}
